<template>
	<view>
		<view class="p-3">
			<view class="bt-block font-12" style="font-weight: 500; color: #343434;">
				<bg-cell >
					项目名称
				</bg-cell>
				<view v-if='dataList.length>0'>
					<bg-cell :border="idx<dataList.length-1" :showArrow="true" @click="gotoDetail(p.projectId)" v-for="p,idx in dataList" :key="idx">
						{{p.projectName}}
					</bg-cell>
				</view>
				<u-empty v-else></u-empty>
				
			</view>
		</view>
		<view class="bt-footer">
			<view class="w-100 text-center">
				<view class="font-12 text-grey1 mb-3">共计 {{total}} 条</view>
				<bg-btn style="background-color: #ffefe7;color:#EE3636;">
					共计待发金额：{{totalAmount}}元
				</bg-btn>
			</view>
			
		</view>
	</view>
</template>

<script>
	import { toSend, toSendTotal } from '../../../api/apply'
	export default {
		data() {
			return {
				dataList:[],
				total:'',
				totalAmount:0,
			}
		},
		mounted() {
			this.getList()
			this.getTotal()
			uni.$on("refresh-grant", ()=>{
				this.getList()
				this.getTotal()
			})
		},
		methods: {
			getList(){
				toSend(this.params).then(res=>{
					this.dataList =res.data.rows
					this.total = res.data.total
				})
			},
			getTotal(){
				toSendTotal(this.params).then(res=>{
					this.totalAmount = res.data
				})
			},
			gotoDetail(pid){
				uni.navigateTo({
					url:"/pages/project/grant/detail?show=true&pid="+pid + "&total=" + this.totalAmount+ "&type=df"
				})
			}
		}
	}
</script>

<style>

</style>
